//
//  NSMutableSet+WeakReference.m
//  MFWSdk
//
//  Created by Song Xiaofeng on 13-7-24.
//  Copyright (c) 2013年 Mafengwo Inc. All rights reserved.
//

#import "NSMutableSet+WeakReference.h"
#import "WeakReference.h"
#import "LoadableCategory.h"

MAKE_CATEGORIES_LOADABLE(MFWSdk_NSMutableSet_WeakReference)

@implementation NSMutableSet (WeakReference)
- (void)addWeakObject:(id)object;
{
    [self addObject:[WeakReference weakReferenceWithObject:object]];
}

- (void)removeWeakObject:(id)object;
{
    [self removeObject:[WeakReference weakReferenceWithObject:object]];
}

- (id)anyWeakObject;
{
    WeakReference *weakRef = [self anyObject];
    if ([weakRef isKindOfClass:[WeakReference class]])
    {
        return [weakRef nonretainedObjectValue];
    }
    return nil;
}

- (BOOL)containsWeakObject:(id)anObject;
{
    return [self containsObject:[WeakReference weakReferenceWithObject:anObject]];
}


@end
